<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>

</head>
<body>
<script type="text/javascript">
   function updateCar(id,itemNum){
	 
	 var regexp = /^[0-9]+$/;
	 if(regexp.test(itemNum)){
		 if(itemNum<= 100){
			var url  = "/myday10/UpdateCarServlet?id="+id+"&itemNum="+itemNum;
			 window.location.href = url;
		 }else{
			 window.alert("个人购买图书数量必须小于100！");
		 }
		 
		 
	 }else{
		 window.alert("图书数量必须输入！");
	 }

   }


</script>

<a>查看最近购买记录</a>
<table border="1" align="center" width="80%">
       <caption>图书购买信息</caption>
        <tr>
          
           <th>书名</th>
           <th>作者</th>
           <th>单价</th>
           <td>数量</td>
           <td>单项总价</td>
         </tr>
     <c:forEach  var="entry"  items="${car.bookMap}">
         <tr>
           <td>${entry.value.book.name}</td>
           <td>${entry.value.book.author}</td>
           <td>${entry.value.book.price}</td>
           <td><input type="text"  value="${entry.value.itemNum}" size="1" onblur="updateCar(${entry.value.book.id },this.value)"/></td>
           <td>${entry.value.itemPrice}</td>
           <td><a href="/myday10/DeleteBookServlet?id=${entry.value.book.id }">删除</a></td>
         </tr>
   
   
     </c:forEach>
     <tr>
       <th colspan="5">总计：￥${ car.totalPrice}
                           <a href="/myday10/ClearCarServlet">清空购物车</a>
                           <a href="/myday10/BookServlet">继续购物</a>
       </th>
      
     
     <tr>
   </table>
 
</body>
</html>